package com.struts.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.commons.beanutils.Converter;

public class UtilDateConverter implements Converter {

	@SuppressWarnings("rawtypes")
	public Object convert(Class type, Object value) {
		Date d= null;
		System.out.println("UtilDateConverter.value="+value);
		if(value==null){
			return value;
		}
		if(value instanceof Date){
			return value;
		}
		if(value instanceof String){
			SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
			try {
				d=sdf.parse((String)value);
			} catch (ParseException e) {
				e.printStackTrace();
			}
		}
		return d;
	}

}
